//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.liy.framework.common.extvo;

import java.io.Serializable;
import java.util.HashMap;

public class ResultVO extends HashMap<String, Object> implements Serializable {
    private static final long serialVersionUID = -2060002093487337950L;
    private boolean success = true;
    private String message = "操作成功";
    private String status = "200";
    private Object data;

    public ResultVO() {
        this.initJson();
    }

    public ResultVO(boolean success) {
        this.setSuccess(success);
        this.initJson();
    }

    public ResultVO(boolean success, String message) {
        this.message = message;
        this.setSuccess(success);
        this.initJson();
    }

    public ResultVO(boolean success, String message, String status) {
        this.success = success;
        this.message = message;
        this.status = status;
        this.initJson();
    }

    public ResultVO(boolean success, String message, String status, Object data) {
        this.message = message;
        this.data = data;
        this.setSuccess(success, status);
        this.initJson();
    }

    private void initJson() {
        this.put("success", this.success);
        this.put("message", this.message);
        this.put("status", this.status);
        this.put("data", this.data);
        this.put("timestamp", System.currentTimeMillis());
    }

    public boolean isSuccess() {
        Object obj = this.get("success");
        return obj != null && obj.toString().length() > 0 ? Boolean.parseBoolean(this.get("success").toString()) : false;
    }

    public void setSuccess(boolean success) {
        this.success = success;
        this.status = success ? "200" : "500";
        this.put("success", success);
        this.put("status", this.status);
    }

    public void setSuccess(boolean success, String status) {
        this.success = success;
        this.status = status;
        this.put("success", success);
        this.put("status", status);
    }

    public String getMessage() {
        Object obj = this.get("message");
        return obj != null && obj.toString().length() > 0 ? obj.toString() : "";
    }

    public void setMessage(String message) {
        this.message = message;
        this.put("message", message);
    }

    public Object getData() {
        Object obj = this.get("data");
        return obj != null && obj.toString().length() > 0 ? obj : "";
    }

    public void setData(Object data) {
        this.data = data;
        this.put("data", data);
    }

    public String getStatus() {
        Object obj = this.get("status");
        return obj != null && obj.toString().length() > 0 ? obj.toString() : "";
    }

    public void setStatus(String status) {
        this.status = status;
        this.put("status", status);
    }
}
